package cn.tedu.front.modify.service.impl;

import cn.tedu.common.pojo.authentication.CurrentPrincipal;
import cn.tedu.front.modify.dao.persist.repository.IUpdateRepository;
import cn.tedu.front.modify.pojo.entity.Details;
import cn.tedu.front.modify.pojo.param.DetailsUpdateParam;
import cn.tedu.front.modify.service.IUpdateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UpdateServiceImpl implements IUpdateService {
    @Autowired
    private IUpdateRepository iUpdateRepository;

    @Override
    public void updateInfo(CurrentPrincipal principal, DetailsUpdateParam detailsUpdateParam) {
        log.debug("开始处理【修改基本信息】的业务，当事人：{}，新基本信息：{}", principal, detailsUpdateParam);
        Long userId = principal.getId();
        Details details = new Details();
        BeanUtils.copyProperties(detailsUpdateParam,details);
        details.setGmtCreate(details.getGmtCreate());
        details.setGmtModified(details.getGmtModified());
        details.setId(userId);
        iUpdateRepository.updateById(details);
    }
}
